﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TSNPro.DeviceConfig;
using TSNPro.Utils;

namespace TSNPro
{
    struct CommonDeviceParam
    {
        double BurningZoneTemperature;
        double GasificationZoneTemperature;
        double BackPressure;

        double CarrierGas;
        double ImportedOxyGen;
        double PyrolysisOxygen;
        double NitrogenOzone;
    }

    public class AppConfig
    {
        private static AppConfig _instance;
        private static readonly object lockObj = new object();
        private IniFile _iniFile;

        // 私有构造函数，防止外部实例化
        private AppConfig()
        {
            string deviceType = JsonUtils.GetDeviceType();
            string fileName = $"./Config/{deviceType}/{"AppConfig.ini"}";
            _iniFile = new IniFile(fileName);
        }

        // 单例模式，确保全局只有一个实例
        public static AppConfig GetInstance()
        {
            lock (lockObj)
            {
                if (_instance == null)
                {
                    _instance = new AppConfig();
                }
                return _instance;
            }
        }

        // 获取配置项
        public string Read(string section, string key)
        {
            return _iniFile.Read(section, key);
        }

        // 设置配置项
        public void Write(string section, string key, string value)
        {
            _iniFile.Write(section, key, value);
        }
    }
}
